<template>
  <div class="home-left-bottom-wrapper">
    <comp-title  :text="title" ref="compTitle"></comp-title>
    <tableItem
      ref="rbTable"
      :data="showdata ? showdata :[]"
      :tbTitle="tbTitle"
      :tbStyle="tbStyle"
    ></tableItem>
    <img src="../../../assets/imgs/left/bottomBg.png" class="bt-bg" ref="btBg" />
  </div>
</template>

<script>
import { mapState } from 'vuex'
import CompTitle from '@/components/common/compTitle.vue'
import tableNumber from './tableNumber'
import tableItem from './tableItem'
import axios from 'axios'
export default {
  components: {
    CompTitle,
    tableNumber,
    tableItem
  },
  data() {
    return {
      titleList: [],
      data: [],
      title:'',
      showdata:[],
      tbTitle: ['指标名称', '指标值', '指标环比'],
      tbStyle: {
        title1Width: '43%',
        title2Width: '43%'
      }
    }
  },
  created() {},
  mounted() {
    //todo
    this.getData();
  },
  computed: {
    // ...mapState(['dataSet'])
  },
  watch: {},
  methods: {
    //todo
    getData() {
      var data = { 'account': '2020-06', 'tenant_id': 'uni099' }
      axios.post(apiUrl + 'api/bigscreen/activitytotal', data).then(res => {
        this.title = '活动总数表格'
        var actTotal={'base':'活动总数','questionNum':res.data[0].activity_total,'haveDeal':res.data[0].activity_total_mom,'tag':res.data[0].activity_total_mom.indexOf("-")<0 ? 'up':'down'};
        var actTargetPersonNum = {'base':'活动目标人数','questionNum':res.data[0].activity_users,'haveDeal':res.data[0].activity_users_mom,'tag':res.data[0].activity_users_mom.indexOf("-")<0?'up':'down'};
        var actTouchPersonNum= {'base':'活动目标人数','questionNum':res.data[0].activity_contact_users,'haveDeal':res.data[0].activity_contact_users_mom,'tag':res.data[0].activity_contact_users_mom.indexOf("-")<0?'up':'down'};
        var actTransferSuccessNum= {'base':'成功转换人数','questionNum':res.data[0].activity_conversion_users,'haveDeal':res.data[0].activity_conversion_users_mom,'tag':res.data[0].activity_conversion_users_mom.indexOf("-")<0?'up':'down'};

        this.showdata.push(actTotal);
        this.showdata.push(actTargetPersonNum);
        this.showdata.push(actTouchPersonNum);
        this.showdata.push(actTransferSuccessNum);
      }).catch(err => {
        console.log(err)
      })
    },
    init() {
      let tl = new TimelineMax({})
      tl.add(this.$refs.compTitle.init(), 'start+=0')
      let btBg = TweenMax.from(this.$refs.btBg, 0.3, { opacity: 0 })
      tl.add(this.$refs.rbTable.init(), 'start+=0.2').add(btBg, 'start+=1.1')
      return tl
    }
  }
}
</script>
<style lang='scss' scoped>
.home-left-bottom-wrapper {
  .bt-bg {
    margin-top: -35px;
  }
}
</style>